package com.oxygen.design.visitor.interfaces.impl;

import com.oxygen.design.visitor.interfaces.ComputerPart;
import com.oxygen.design.visitor.interfaces.ComputerPartVisitor;

/**
 * @author wangjie
 * @title: Computer
 * @description: TODO
 * @date 2022/3/30 22:16
 **/
public class Computer implements ComputerPart {

    ComputerPart[] parts;

    public Computer() {
        parts = new ComputerPart[]{new Mouse(), new Keyboard(), new Monitor()};
    }


    @Override
    public void accept(ComputerPartVisitor computerPartVisitor) {
        for (int i = 0; i < parts.length; i++) {
            parts[i].accept(computerPartVisitor);
        }
        computerPartVisitor.visit(this);
    }
}